package com.cj.order.service.impl;

import com.cj.common.exception.BaseException;
import com.cj.common.response.Result;
import com.cj.order.service.StockFeignService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author cheng jun
 * @Description:
 * @Date 2021/5/26 11:31
 */
@Component
@Slf4j
public class StockFeignFallbackFactory implements FallbackFactory<StockFeignService> {

    @Override
    public StockFeignService create(Throwable throwable) {
        return new StockFeignService() {
            @Override
            public Result deleteStock(Map<String, Object> map) {
                log.error(throwable.getMessage());
                throw new BaseException("openfeign调用失败:stock接口------------------------------------------");
            }
        };
    }

}
